<template>
	<view class="">
		<view class="nav_top-bg">
			<u-navbar title="点赞">
				<view class="u-nav-slot" slot="left">
					<u-icon name="arrow-left" @click="go_black" size="19"></u-icon>
					<u-line direction="column" :hairline="false" length="16" margin="0 10px"></u-line>
					<u-icon name="home" @click="goHome" size="20"></u-icon>
				</view>
			</u-navbar>
		</view>
		<view class="" v-if="!dianzan_list.length">
			<u-empty>
			</u-empty>
		</view>
		<!-- 点赞列表 -->
		<view v-else class="dianzan d-flex align-items" v-for="(dianzan,index) in dianzan_list" :key="index">
			<view class="w-650 d-flex align-items justify-content-space-between">
				<view class="d-flex align-items">
					<image class="avart01" :src="dianzan.user.avatar" mode=""></image>
					<view class="mingzi">{{dianzan.user.nickname}}</view>
				</view>
				<view class="long-time">{{dianzan.shijian}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getLikeList
	} from '@/api/user.js'
	export default {
		data() {
			return {
				dianzan_list:[],
				page: 1,
				limit:7,
			}
		},
		onLoad() {
			this.get_dianzan()
		},
		// 用户下拉加载
		onPullDownRefresh() {
			this.page = 1
			this.get_dianzan()
		},
		// 上拉触底加载
		onReachBottom() {
			this.page++
			this.get_dianzan()
		},
		methods: {
			go_black() {
				uni.navigateBack({
					delta: 1
				})
			},
			goHome() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			// 获取留言
			get_dianzan(){
				var data = {
					page: this.page,
					limit: this.limit,
				}
				getLikeList(data).then(res => {
					console.log("获取点赞");
					if(res.code == 1){
						if(this.page == 1){
							this.dianzan_list = res.data.list
						}else {
							this.dianzan_list = this.dianzan_list.concat(res.data.list) 
						}
						uni.stopPullDownRefresh()
					}
				})
			},
		}
	}
</script>

<style>
	.long-time{
		font-size: 24rpx;
		font-weight: normal;
		color: #999999;
	}
	.mingzi{
		font-size: 32rpx;
		font-weight: normal;
		color: #444444;
		margin-left: 20rpx;
	}
	.avart01{
		width: 80rpx;
		height: 80rpx;
		display: block;
		border-radius: 50%;
	}
	.dianzan{
		width: 690rpx;
		height: 140rpx;
		margin: 30rpx auto;
		background: #FFFFFF;
		border-radius: 8rpx;
	}
	page {
		background-color: #F7F8FB;
	}
</style>